package com.mcxx.context;

import com.mcxx.handler.BizProcessHandler;
import com.yinhai.ta404.core.utils.ServiceLocator;

import java.util.Map;


public class BizHandlerContext {
    private Map<String, Class> handlerMap;

    public BizHandlerContext(Map<String, Class> handlerMap) {
        this.handlerMap = handlerMap;
    }


    public BizProcessHandler getInstance(HandleType handleType) {
        Class claz = handlerMap.get(handleType.toKey());
        if(null == claz) {
            throw new IllegalArgumentException("Can not find class for type : " + handleType.toKey());
        }
        return (BizProcessHandler) ServiceLocator.getAppContext().getBean(claz);
    }
}
